import {
	storage
} from '@/common/storage.js'

const apiHost = {
	'test': 'http://222.44.91.49:8080/party-building-server',
	'product': 'https://jk.railshj.com/party-building-server',
	'jndev': 'http://222.44.111.10:18003/party-building-server-dev',
	'jntest': 'http://222.44.111.11:18004/party-building-server-test',
	'pndev': 'http://222.44.91.49:8080/party-building-server-pndev',
	'pntest': 'http://222.44.91.49:8080/party-building-server-pntest',
	'pnprd': 'https://jk.railshj.com/party-building-server-pnprd',
}
export const getBaseUrl = () => {
	let baseUrl;
	try {
		const environment = storage.getStorageDataSync('environment')
		baseUrl = apiHost[environment] || apiHost['product'];
		return baseUrl
	} catch (err) {
		baseUrl = apiHost['product']
		return baseUrl
	}
}

const smartLockApiHost = {
	'test': 'http://222.44.91.49:8080/smart-lock-app-backend',
	'product': 'https://jk.railshj.com/smart-lock-app-backend',
	'jndev': 'http://222.44.111.10:18003/smart-lock-app-backend-dev',
	'jntest': 'http://222.44.111.11:18004/smart-lock-app-backend-test',
	'pndev': 'http://222.44.91.49:8080/smart-lock-app-backend',
	'pntest': 'http://222.44.91.49:8080/smart-lock-app-backend',
	'pnprd': 'https://jk.railshj.com/smart-lock-app-backend',
}

export const getSmartLockBaseUrl = () => {
	let smartLockBaseUrl;
	try {
		const environment = storage.getStorageDataSync('environment')
		smartLockBaseUrl = smartLockApiHost[environment] || smartLockApiHost['product'];
		return smartLockBaseUrl
	} catch (err) {
		smartLockBaseUrl = apiHost['product']
		return smartLockBaseUrl
	}
}